package com.ruoyi.web.controller.monitor;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.monitor.domain.BusFlowmeterMonitordata;
import com.ruoyi.monitor.service.IBusFlowmeterMonitordataService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 水文点位监测数据Controller
 *
 * @author ruoyi
 * @date 2025-08-20
 */
@RestController
@RequestMapping("/monitor/flowmeter")
public class BusFlowmeterMonitordataController extends BaseController {
    @Autowired
    private IBusFlowmeterMonitordataService busFlowmeterMonitordataService;

    /**
     * 查询水文点位监测数据列表
     */
//    @PreAuthorize("@ss.hasPermi('monitor:flowmeter:list')")
    @GetMapping("/list")
    public TableDataInfo list(BusFlowmeterMonitordata busFlowmeterMonitordata) {
        startPage();
        List<BusFlowmeterMonitordata> list = busFlowmeterMonitordataService.selectBusFlowmeterMonitordataList(busFlowmeterMonitordata);
        return getDataTable(list);
    }

    /**
     * 导出水文点位监测数据列表
     */
//    @PreAuthorize("@ss.hasPermi('monitor:flowmeter:export')")
//    @Log(title = "水文点位监测数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BusFlowmeterMonitordata busFlowmeterMonitordata) {
        List<BusFlowmeterMonitordata> list = busFlowmeterMonitordataService.selectBusFlowmeterMonitordataList(busFlowmeterMonitordata);
        ExcelUtil<BusFlowmeterMonitordata> util = new ExcelUtil<BusFlowmeterMonitordata>(BusFlowmeterMonitordata.class);
        util.exportExcel(response, list, "水文点位监测数据数据");
    }

    /**
     * 获取水文点位监测数据详细信息
     */
//    @PreAuthorize("@ss.hasPermi('monitor:flowmeter:query')")
    @GetMapping(value = "/{guid}")
    public AjaxResult getInfo(@PathVariable("guid") String guid) {
        return success(busFlowmeterMonitordataService.selectBusFlowmeterMonitordataByGuid(guid));
    }

    /**
     * 新增水文点位监测数据
     */
//    @PreAuthorize("@ss.hasPermi('monitor:flowmeter:add')")
//    @Log(title = "水文点位监测数据", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody BusFlowmeterMonitordata busFlowmeterMonitordata) {
        return toAjax(busFlowmeterMonitordataService.insertBusFlowmeterMonitordata(busFlowmeterMonitordata));
    }

    /**
     * 修改水文点位监测数据
     */
//    @PreAuthorize("@ss.hasPermi('monitor:flowmeter:edit')")
//    @Log(title = "水文点位监测数据", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody BusFlowmeterMonitordata busFlowmeterMonitordata) {
        return toAjax(busFlowmeterMonitordataService.updateBusFlowmeterMonitordata(busFlowmeterMonitordata));
    }

    /**
     * 删除水文点位监测数据
     */
//    @PreAuthorize("@ss.hasPermi('monitor:flowmeter:remove')")
//    @Log(title = "水文点位监测数据", businessType = BusinessType.DELETE)
    @GetMapping("/{guids}")
    public AjaxResult remove(@PathVariable String[] guids) {
        return toAjax(busFlowmeterMonitordataService.deleteBusFlowmeterMonitordataByGuids(guids));
    }

    /**
     * 查询水文点位监测数据列表
     */
    @GetMapping(value = "/selectmonitor")
    public AjaxResult selectmonitor(String riverid, String starttime, String endtime, String stationname) {
        return AjaxResult.success(busFlowmeterMonitordataService.selectBusFlowmeterMonitordata(riverid, starttime, endtime, stationname));
    }
}
